<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title>服务列表</title>
    <link rel="stylesheet" th:href="@{/static/css/common.css}" />
    <link rel="stylesheet" th:href="@{/static/css/bootstrap.min.css}"/>
    <link rel="stylesheet" th:href="@{/static/css/bootstrap-theme.css}"/>
    <script type="text/javascript" th:src="@{/static/js/jquery-3.3.1.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/bootstrap.min.js}"></script>
</head>
<body>
<div class="row">
    <div id="home_left" class="col-sm-2" th:insert="~{home :: home_left}">
    </div>
    <div class="col-sm-8">
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">Panel heading</div>

            <!-- Table -->
            <table class="table">
                <thead>
                <tr class="alert-info active table-">
                    <td><b>执行器任务handler</b></td>
                    <td><b>执行器路由策略</b></td>
                    <td><b>调度类型</b></td>
                    <td><b>调度参数</b></td>
                    <td><b>超时时间</b></td>
                    <td><b>失败重试次数</b></td>
                    <td><b>作者</b></td>
                    <td><b>执行状态</b></td>
                    <td><b>上次执行时间</b></td>
                    <td><b>下次执行时间</b></td>
                    <td><b>操作</b></td>
                </tr>
                </thead>
                <tbody id="table-content">
                </tbody>
            </table>
        </div>

    </div>
</div>
</body>
<script type="text/javascript">

    $(document).ready(function () {
        getJobList();
    });

    function getJobList() {
        $.ajax({
            url: "http://localhost:9200/job", //请求路径
            type: "GET", //请求方式
            dataType: "json",//设置接受到的响应数据的格式
            //回调函数
            success: function (data) {
                if (data) {
                    for (i = 0, len = data.length; i < len; i++) {
                        $('#table-content').append('<tr>');
                        $('#table-content').append('<td>' + data[i].executorHandler + '</td>');
                        $('#table-content').append('<td>' + data[i].executorRouteStrategy + '</td>');
                        $('#table-content').append('<td>' + data[i].scheduleType + '</td>');
                        $('#table-content').append('<td>' + data[i].executorParam ? data[i].executorParam : '' + '</td>');
                        $('#table-content').append('<td>' + data[i].executorTimeout + '</td>');
                        $('#table-content').append('<td>' + data[i].executorFailRetryCount + '</td>');
                        $('#table-content').append('<td>' + data[i].author + '</td>');
                        $('#table-content').append('<td>' + data[i].triggerStatus + '</td>');
                        $('#table-content').append('<td>' + data[i].triggerLastTime + '</td>');
                        $('#table-content').append('<td>' + data[i].triggerNextTime + '</td>');
                        $('#table-content').append('<td>' + '<a class="nav-link" target="_blank" href="/log?name=' + data[i].executorHandler + '">' + '日志' + '</a></td>');
                        $('#table-content').append('</tr>');
                    }
                }
            },
            error: function () {
                console.log("获取任务信息失败...")
            }
        })
    }
</script>
</html>